<?php $this->fetch('public/head') ?>
<div class="layui-tab layui-tab-brief" xmlns="http://www.w3.org/1999/html">
    <ul class="layui-tab-title">
        <li class="layui-this">成员列表</li>
    </ul>
    <div class="layui-tab-content layui-form">
        <div id="ss" class="layui-form layui-form-pane">
            <div class="layui-inline">
                <label class="layui-form-label">总金额</label>
                <div class="layui-input-inline">
                    <input name="amount" class="layui-input" value="<?php echo $amount ?>" readonly>
                </div>
            </div>
        </div>
        <hr>
        <form class="layui-form form-container" action="<?php echo url('put_reward')?>" method="post">
            <input name="reward" type="hidden" class="layui-input" value="<?php echo $amount ?>" readonly>
            <div class="layui-form-item">
                <label class="layui-form-label">金额列表</label>
                <?php foreach ($task_list as $v){?>
                <div class="layui-input-block">
                    <div id="photo-container">
                        <div class="photo-list">
                            <input type="text" name="username[]" value="<?php echo $v['user_name'] ?>"  maxlength="100" readonly class="layui-input layui-input-inline">
                            <input type="text" name="amount[]" value="<?php echo $v['amount']/100 ?>" class="layui-input layui-input-inline">
                            <input type="hidden" name="userid[]" value="<?php echo $v['user_id'] ?>" >
                        </div>
                    </div>
                </div>
                <?php }?>
            </div>
            <input type="hidden" name="relation_id" value="<?php echo $task_list[0]['jdz_id']?>">
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="go">确认发放</button>
                </div>
            </div>
        </form>
    </div>
</div>
<?php $this->fetch('public/script') ?>

<script>

    layui.use(['form'], function () {
        var table = layui.table
            , form = layui.form;
        form.on('submit(go)', function (data) {
            let loading = layer.load(0); //0代表加载的风格，支持0-2
            $.ajax({
                url: data.form.action,
                type: data.form.method,
                data: $(data.form).serialize(),
                success: function (info) {
                    if (info.code === 1) {
                        setTimeout(function () {
                            layer.close(loading); //关闭加载层
                            window.parent.layer.closeAll()
                            location.reload();
                        }, 1000);
                    }
                    layer.msg(info.msg);
                }
            });
            return false;
        });
        //监听复选框选择
        table.on('checkbox(dataList)', function (obj) {
            let checkStatus = table.checkStatus('dataList')
                , data = checkStatus.data;//包含行信息的data二维
            $('.checkedNum').text(data.length)
        });

    });
</script>